# -*- coding: utf-8 -*-
"""
活动管理 - Django Admin配置
"""

from django.contrib import admin
from .models import (
    ActivityType, Activity, ActivityRegistration, 
    GroupRegistration, ActivityCheckIn, ActivityLive
)


@admin.register(ActivityType)
class ActivityTypeAdmin(admin.ModelAdmin):
    """活动类型管理"""
    list_display = ('name', 'is_system', 'sort_order', 'created_at')
    list_filter = ('is_system',)
    search_fields = ('name',)
    ordering = ('-sort_order', 'name')


@admin.register(Activity)
class ActivityAdmin(admin.ModelAdmin):
    """活动管理"""
    list_display = ('title', 'activity_type', 'creator', 'status', 'start_time', 'current_participants', 'max_participants', 'created_at')
    list_filter = ('status', 'activity_type', 'is_free', 'created_at')
    search_fields = ('title', 'description', 'location_name')
    date_hierarchy = 'start_time'
    ordering = ('-created_at',)
    raw_id_fields = ('creator',)


@admin.register(ActivityRegistration)
class ActivityRegistrationAdmin(admin.ModelAdmin):
    """活动报名管理"""
    list_display = ('user', 'activity', 'status', 'is_checked_in', 'registered_at')
    list_filter = ('status', 'is_checked_in', 'registered_at')
    search_fields = ('user__username', 'activity__title')
    raw_id_fields = ('user', 'activity')


@admin.register(ActivityCheckIn)
class ActivityCheckInAdmin(admin.ModelAdmin):
    """活动签到管理"""
    list_display = ('registration', 'points_earned', 'checked_in_at')
    list_filter = ('checked_in_at',)
    search_fields = ('registration__user__username', 'registration__activity__title')
    raw_id_fields = ('registration',)


@admin.register(ActivityLive)
class ActivityLiveAdmin(admin.ModelAdmin):
    """活动直播管理"""
    list_display = ('activity', 'title', 'status', 'viewer_count', 'start_time')
    list_filter = ('status', 'start_time')
    search_fields = ('title', 'activity__title')
    raw_id_fields = ('activity',)


# 简单注册其他模型
admin.site.register(GroupRegistration)
